﻿using MediatR;
using MS.Data.API.Write.Applicant.Command;
using MS.Data.API.Write.Applicant.Command.RoleInfo;
using MS.Data.Domain;
using MS.Data.ErrorCode;
using MS.Data.Infratructrue.Istanbul;

namespace MS.Data.API.Write.Applicant.CommandHandel.RoleInfo
{
    public class FeningCommandHandel : IRequestHandler<FeningCommand, APIResult<List<Role>>>
    {
        IBaseRepository<Role> roleRep;

        public FeningCommandHandel(IBaseRepository<Role> roleRep)
        {
            this.roleRep = roleRep;
        }

        public Task<APIResult<List<Role>>> Handle(FeningCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<Role>> result = new APIResult<List<Role>>();
            result.code = APIEnum.更新成功;
            result.mes = APIEnum.更新成功.ToString();

            var list = roleRep.GetAll().Where(s => s.RoleId == request.RoleId);

            result.data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
